package com.rock.demo.sptest.designmodel.observe;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/v1/test")
public class ObserverController {
    @Autowired
    private ApplicationContext applicationContext;

    @GetMapping("/test")
    public String test() {
        OrderObservable order = new OrderObservable(this, "order something");
        applicationContext.publishEvent(order);
        return "success";
    }
}
